package com.ruoyi.web.controller.environment;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.environment.domain.EnvShouxu;
import com.ruoyi.environment.service.IEnvShouxuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 环评报告，批复及竣工验收Controller
 * 
 * @author ruoyi
 * @date 2021-09-14
 */
@RestController
@RequestMapping("/environment/shouxu")
public class EnvShouxuController extends BaseController
{
    @Autowired
    private IEnvShouxuService envShouxuService;

    /**
     * 查询环评报告，批复及竣工验收列表
     */
    @PreAuthorize("@ss.hasPermi('environment:shouxu:list')")
    @GetMapping("/list")
    public TableDataInfo list(EnvShouxu envShouxu)
    {
        startPage();
        List<EnvShouxu> list = envShouxuService.selectEnvShouxuList(envShouxu);
        return getDataTable(list);
    }

    /**
     * 导出环评报告，批复及竣工验收列表
     */
    @PreAuthorize("@ss.hasPermi('environment:shouxu:export')")
    @Log(title = "环评报告，批复及竣工验收", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EnvShouxu envShouxu)
    {
        List<EnvShouxu> list = envShouxuService.selectEnvShouxuList(envShouxu);
        ExcelUtil<EnvShouxu> util = new ExcelUtil<EnvShouxu>(EnvShouxu.class);
        return util.exportExcel(list, "环评报告，批复及竣工验收数据");
    }

    /**
     * 获取环评报告，批复及竣工验收详细信息
     */
    @PreAuthorize("@ss.hasPermi('environment:shouxu:query')")
    @GetMapping(value = "/{esId}")
    public AjaxResult getInfo(@PathVariable("esId") Long esId)
    {
        return AjaxResult.success(envShouxuService.selectEnvShouxuById(esId));
    }

    /**
     * 新增环评报告，批复及竣工验收
     */
    @PreAuthorize("@ss.hasPermi('environment:shouxu:add')")
    @Log(title = "环评报告，批复及竣工验收", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EnvShouxu envShouxu)
    {
        return toAjax(envShouxuService.insertEnvShouxu(envShouxu));
    }

    /**
     * 修改环评报告，批复及竣工验收
     */
    @PreAuthorize("@ss.hasPermi('environment:shouxu:edit')")
    @Log(title = "环评报告，批复及竣工验收", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EnvShouxu envShouxu)
    {
        return toAjax(envShouxuService.updateEnvShouxu(envShouxu));
    }

    /**
     * 删除环评报告，批复及竣工验收
     */
    @PreAuthorize("@ss.hasPermi('environment:shouxu:remove')")
    @Log(title = "环评报告，批复及竣工验收", businessType = BusinessType.DELETE)
	@DeleteMapping("/{esIds}")
    public AjaxResult remove(@PathVariable Long[] esIds)
    {
        return toAjax(envShouxuService.deleteEnvShouxuByIds(esIds));
    }
}
